package com.controller;

import com.beans.Userinfo;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import javax.servlet.http.HttpServlet;
import java.util.List;

/**
 * @author 李琦 on 2021/10/20.
 * @version java version "1.8.0_301" 2021-04-20
 * uuid,雪花id
 */
@RestController//间接继承到servlet    spring mvc封装了servlet
@RequestMapping("/userinfo")//映射地址
public class UserinfoController extends HttpServlet {

    @Resource UserinfoInterface userinfoInterface;

    @RequestMapping (value = "/save")
    public String userinfoGetMsg(Userinfo userinfo){
        Userinfo uu=userinfoInterface.save(userinfo);//保存到数据库
//        System.out.println(userinfo.getName());
//        System.out.println(userinfo.getAge());
//        System.out.println(userinfo.getAclass());
//        System.out.println(userinfo.getPassword());
        return "";
    }
    @PostMapping("/del")
    public void userinfoDel(Integer id){
        userinfoInterface.deleteById(id);

    }

    @GetMapping("/del1")
    public String  userinfoDel1(String name){
        int a=userinfoInterface.deleteUserinfoByName(name);
        System.out.println(a);
        return "";

    }
    @PostMapping("queryAll")
    public List<Userinfo> query(){
        return userinfoInterface.findAll();


    }


}
